Skip to content

fix(renderer): guard malformed part render in flush#347

Merged
sudo-tee merged 4 commits intosudo-tee:refactor/renderer-componentsfrom
jensenojs:refactor/renderer-components
Apr 7, 2026
Merged

fix(renderer): guard malformed part render in flush#347
sudo-tee merged 4 commits intosudo-tee:refactor/renderer-componentsfrom
jensenojs:refactor/renderer-components

Conversation

@jensenojs
Copy link
Copy Markdown
Contributor

This seems to be the simplest fix

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the Neovim output renderer against malformed tool parts by preventing formatter.format_part errors from crashing a flush, and adds a replay regression test driven by a real malformed todowrite payload fixture.

Changes:

  • Guard formatter.format_part with pcall during flush and skip malformed parts while emitting a warning.
  • Add a replay test that renders a recorded malformed todowrite session without crashing.
  • Add a JSON fixture containing a real malformed todowrite tool call (todos encoded as a string instead of an array).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
lua/opencode/ui/renderer/flush.lua Wraps part formatting in pcall and warns once instead of crashing the renderer flush.
tests/replay/todowrite_malformed_session_spec.lua Adds a regression spec that replays malformed session data and asserts the renderer doesn’t crash.
tests/data/todowrite-malformed-session.json Adds a real-world session fixture containing the malformed todowrite payload.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lua/opencode/ui/renderer/flush.lua Outdated
Comment thread tests/data/todowrite-malformed-session.json Outdated
Comment thread tests/data/todowrite-malformed-session.json Outdated
@sudo-tee sudo-tee merged commit 74a74bc into sudo-tee:refactor/renderer-components Apr 7, 2026
5 checks passed
@sudo-tee
Copy link
Copy Markdown
Owner

sudo-tee commented Apr 7, 2026

Thanks for this fix

@jensenojs jensenojs deleted the refactor/renderer-components branch April 7, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants